import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;



	public class Simp{
		public static void main (String[]args){
		
		List<Stud> list= new ArrayList<Stud>();
		 Stud s1=new Stud(10,"Ravi",23);
		 Stud s2=new Stud(12,"Mahesh",18);
		 Stud s3=new Stud(11,"Kumar",25);
		list.add(s1);
		list.add(s2);
		list.add(s3);
		Collections.sort(list);
		for(Stud ss:list){
			
			System.out.println(ss.getName());
		}

		Iterator itr=list.iterator();
		while(itr.hasNext()){
			
			Stud st=(Stud)itr.next();
			System.out.println(st.getRollno()+"  "+st.getName()+ " "+st.getAge());
		}
		Stud n=new Stud();
		Collections.sort(list,new Stud());
          for(Stud ss:list){
			
			System.out.println(ss.getRollno());
		}
		
}

}

class Stud implements Comparable <Stud> ,Comparator<Employee>{
	private int rollno;
	private String name;
	private int age;
	Stud(){
		
	}
	
	public String getName(){
		
		return name;
	}
	
	public String setName(String name){
		return this.name;
		
	}

public int getRollno(){
		
		return rollno;
	}
	
	public int setRollno(int rollno){
		return this.rollno;
		
	}
public int getAge(){
		
		return age;
	}
	
	public int setAge(String age){
		return this.age;
		
	}
	public Stud(int rollno, String name, int age){
		 this.rollno=rollno;
		 this.name=name;
		 this.age=age;
	 }
	 public String toString(){
		 
		 return this.name;
		 
	 }
	 
	 public int compareTo(Stud s){
		 return name.compareTo(s.getName());
		 
	 }
	 public int compare(Stud d, Stud d1){
	      return d.age - d1.age;
	   }
	
	
}

